<%@ page language="java" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%
	Object obj = request.getSession().getAttribute("role_resource");
	if (null == obj) {
		response.setStatus(1000);
		return;
	}
%>

<script type="text/javascript">
		//素材列表数据源
		var data_store = new Ext.data.JsonStore({
    		root: "data",
    		totalProperty: "total",
    		fields: ["id","name","type","docname","begin","end","state","url","remark","personno","personname","createtime"],
    		url: "fodder!list.action"
    	});
    	//素材状态下拉列表
    	var state_store = new Ext.data.JsonStore({
			fields: ["id", "text"],
			data: [{id:"0",text:"退回"},{id:"1",text:"启用"},{id:"2",text:"草稿"},{id:"3",text:"审核中"}]
		});
		//素材类别下拉列表
    	var type_store = new Ext.data.JsonStore({
			fields: ["id", "text"],
			data: [{id:"1",text:"图片"},{id:"2",text:"文字"}]
		});
    	//素材状态下拉列表
    	var state_store1 = new Ext.data.JsonStore({
			fields: ["id", "text"],
			data: [{id:"",text:"全部"},{id:"0",text:"退回"},{id:"1",text:"启用"},{id:"2",text:"草稿"},{id:"3",text:"审核中"}]
		});
		//素材类别下拉列表
    	var type_store1 = new Ext.data.JsonStore({
			fields: ["id", "text"],
			data: [{id:"",text:"全部"},{id:"1",text:"图片"},{id:"2",text:"文字"}]
		});

			//定义数据显示面板
			var p1 = {
				id: "p1",
				xtype: "grid",
				stripeRows: true,
				loadMask: true,
				autoExpandColumn: "name",
				store: data_store,
				headersDisabled: true,
				sm: new Ext.grid.RowSelectionModel(),        
				columns:[
	    	    	new Ext.grid.RowNumberer({header: "序号", width: 35}),
    					{header: "编号",		dataIndex: "id",	menuDisabled: true},
    					{header: "素材名称",	dataIndex: "name",	id: "name",	menuDisabled: true},
    					{	header: "素材类型",	
    						dataIndex: "type",
    						menuDisabled: true,
    						renderer: function(input){
    							var res2=type_store.getById(input);
    							return (res2)?res2.data.text:"";
    						}
    					},
    					{header: "文件名",	dataIndex: "docname",	menuDisabled: true},
    					{header: "有效期起始月",	dataIndex: "begin",	menuDisabled: true},
    					{header: "有效期截止月",	dataIndex: "end",	menuDisabled: true},
    					{	header: "状态",	
    						dataIndex: "state",
    						menuDisabled: true,
    						renderer: function(input){
    							var res2=state_store.getById(input);
    							return (res2)?res2.data.text:"";
    						}
    					},
    					{header: "URL",	dataIndex: "url",	menuDisabled: true},
    					{header: "备注",	dataIndex: "remark",	menuDisabled: true},
    					{header: "操作人",	dataIndex: "personname",	menuDisabled: true},
    					{header: "创建时间",	dataIndex: "createtime",width:115, menuDisabled: true},
    					{
    						xtype:"billActionColumn",
    						header: "预览",
    						width:34,
    						dataIndex: "type",
    						items:[{
			                    icon:"images/shared/icons/fam/information.png",  // Use a URL in the icon config
			                    tooltip:"预览",
			                    handler: function(grid, rowIndex, colIndex) {
									var rec = data_store.getAt(rowIndex);
									var win=Ext.getCmp("showimages");
									win.show();
									var html="<img id='imgpage' width="+win.getInnerWidth()+" height="+win.getInnerHeight()+" src='download.action?id="+encodeURI(rec.get('docname'))+"' />";
									win.update(html);
			                    }
			                }],
			                renderer: function(input){
			                	return "1"==input;
    							
    						}
    					}
				],
				tbar: [{
					xtype : "tbtext",
					text : "&nbsp&nbsp素材类型:"
				},{
					xtype : "billCombox",
					width : 120,
					id : "foddertype",
					value:"",
					store : type_store1,
					listeners : {
						'select':function(){
							data_store.baseParams["fodder.type"] = this.value ;
							data_store.load({params:{start:0,limit:limit}});
							
						}
					}
				},{
					xtype : "tbtext",
					text : "&nbsp&nbsp状态:"
				},{
					xtype : "billCombox",
					width : 120,
					id : "fodderstate",
					value:"",
					store : state_store1,
					listeners : {
						'select':function(val){
							data_store.baseParams["fodder.state"] = this.value ;	
							data_store.load({params:{start:0,limit:limit}});						
						}
					}
				}],				
				bbar: new Ext.ux.PagingToolbar({
    	        	pageSize: limit,
    	        	store: data_store
    	    	})
			};
			
		data_store.load({params:{start:0,limit:limit}});
				
		var CenterPanel=Ext.getCmp("CenterPanel");
		CenterPanel.removeAll();
		CenterPanel.add(p1);
		CenterPanel.doLayout();
	</script>
